
#include <assert.h>
#include "clist.h"


SList StlcListCreate( size_t a_szTypeSize, const char* a_pcTypeName )
{
	SList stList;
	assert( a_szTypeSize > 0 && NULL != a_pcTypeName );
	memset( &stList, 0, sizeof( stList ) );
	stList.eContainerType = ECRT_LIST;
	StlcUnifyTypes( &stList.stStlcType, a_szTypeSize, a_pcTypeName, NULL );	
	return stList;
}

void StlcListInit( PSList a_pstList, PFCompare a_pfnCompare )
{
	StlcListInitN( a_pstList, a_pfnCompare, 0 );
}

void StlcListInitN( PSList a_pstList, PFCompare a_pfnCompare, size_t a_szCount )
{
	assert( NULL != a_pstList );
	StlcListInitElem( a_pstList, a_pfnCompare, a_szCount, 0x00 );
}

void StlcListInitElem( PSList a_pstList, PFCompare a_pfnCompare, size_t a_szCount, ... )
{
	va_list pArgList;
	size_t  i = 0;
	void*  pInitElem = NULL;
	assert( NULL != a_pstList && 0 == a_pstList->szNodeCnt && NULL == a_pstList->stListNode.pstPrev 
		&& NULL == a_pstList->stListNode.pstNext && NULL == a_pstList->stListNode.pcValue && NULL == a_pstList->pfnCompare );
	va_start( pArgList, a_szCount );
	/*if( a_szCount > 0 )
	{
		a_pstVector->pcStart = (char*)StlcAlloc( a_pstVector->szTypeSize * 2 * a_szCount );
		assert( NULL != a_pstVector->pcStart );
		a_pstVector->pcFinish = a_pstVector->pcStart + a_pstVector->szTypeSize * a_szCount;
		a_pstVector->pcEndOfStorage = a_pstVector->pcStart + a_pstVector->szTypeSize * 2 * a_szCount;

		pInitElem = StlcAlloc( a_pstVector->szTypeSize );
		assert( NULL != pInitElem );
		StlcGetVargValue( pInitElem, pArgList, a_pstVector->szTypeSize, a_pstVector->cTypeName );
		for( i = 0; i < a_szCount; ++i )
		{
			memcpy(	a_pstVector->pcStart + i * a_pstVector->szTypeSize, pInitElem, a_pstVector->szTypeSize );
		}
		StlcFree( pInitElem );
	}
	a_pstVector->pfnCompare = ( NULL != a_pfnCompare ) ? a_pfnCompare : StlcGetCompareFunction( a_pstVector->cTypeName );*/
}

void StlcListInitCopy( PSList a_pstList, const SList* a_pstListSrc )
{

}

void StlcListInitCopyRange( PSList a_pstList, const SIterator a_stIterBegin, const SIterator a_stIterEnd )
{

}

bool StlcListSameType( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	assert( NULL != a_pstListFirst && NULL != a_pstListSecond );
	return StlcSameType( &a_pstListFirst->stStlcType, &a_pstListSecond->stStlcType );
}

size_t StlcListSize( const SList* a_pstList )
{
	assert( NULL != a_pstList && ECRT_LIST == a_pstList->eContainerType );
	return a_pstList->szNodeCnt;
}

bool StlcListEmpty( const SList* a_pstList )
{
	assert( NULL != a_pstList && ECRT_LIST == a_pstList->eContainerType );
	if( 0 == a_pstList->szNodeCnt )
	{
		assert( NULL == a_pstList->stListNode.pstPrev && NULL == a_pstList->stListNode.pstNext );
		return true;
	}
	else
	{
		assert( NULL != a_pstList->stListNode.pstPrev && NULL != a_pstList->stListNode.pstNext );
		return false;
	}
}

size_t StlcListMaxSize( const SList* a_pstList )
{
	assert( NULL != a_pstList && ECRT_LIST == a_pstList->eContainerType );
	return (size_t)(-1) / a_pstList->stStlcType.szTypeSize;
}

bool StlcListEqual( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	assert( NULL != a_pstListFirst && ECRT_LIST == a_pstListFirst->eContainerType );
	assert( NULL != a_pstListSecond && ECRT_LIST == a_pstListSecond->eContainerType );
	return true;
}

bool StlcListNotEqual( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	return !StlcListEqual( a_pstListFirst, a_pstListSecond );
}

bool StlcListLess( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	return true;
}

bool StlcListGreat( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	return true;
}

bool StlcListLessEqual( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	return true;
}

bool StlcListGreatEqual( const SList* a_pstListFirst, const SList* a_pstListSecond )
{
	return true;
}

void StlcListAssign( PSList a_pstListDest, const SList* a_pstListSrc )
{

}

void StlcListAssignRange( PSList a_pstList, const SIterator *a_pstIterBegin, const SIterator *a_pstIterEnd )
{

}

void StlcListSwap( PSList a_pstListFirst, PSList a_pstListSecond )
{

}

void* StlcListFront( const SList* a_pstList )
{
	return NULL;
}

void* StlcListBack( const SList* a_pstList )
{
	return NULL;
}

SIterator StlcListBegin( const SList* a_pstList )
{
	SIterator stIterator;
	return stIterator;
}

SIterator StlcListEnd( const SList* a_pstList )
{
	SIterator stIterator;
	return stIterator;
}

void StlcListInsertRange( PSList a_pstList, PSIterator a_pstIterator, PSIterator a_pstIterBegin, PSIterator a_pstIterEnd )
{

}

void StlcListPushBack( PSList a_pstList, ... )
{

}

void StlcListPopBack(  PSList a_pstList )
{

}

SIterator   StlcListErasePos( PSList a_pstList, SIterator a_stIterator )
{
	SIterator stIterator;
	return stIterator;
}

SIterator StlcListEraseRange( PSList a_pstList, SIterator a_stIterBegin, SIterator a_stIterEnd )
{
	SIterator stIterator;
	return stIterator;
}

void StlcListClear( PSList a_pstList )
{

}

void StlcListSort( PSList a_pstList, PFSort a_pfnSort, PFCompare a_pfnCompare )
{

}

void* StlcListFind( const SList* a_pstList, ... )
{
	return NULL;
}
void* StlcListFindN( const SList* a_pstList, size_t a_szIndex, ... )
{
	return NULL;
}

//SIterator StlcListSearch( const SList* a_pstList, PFSearch a_pfnSearch, PFCompare a_pfnCompare, ... )
//{
//
//}
//SIterator StlcListSearchN( const SList* a_pstList, PFSearch a_pfnSearch, PFCompare a_pfnCompare, size_t a_szIndex, ... );
void StlcListDestroy( PSList a_pstList )
{

}


//SIterator   StlcListIteratorCreate(void);
//bool StlcListIteratorBelongTo( const SList* a_pstList, const SIterator a_stIterator );
//bool StlcListIteratorEqual( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
//void StlcListIteratorGetValue( const SList* a_pstList,const SIterator a_stIterator, void* a_pValue );
//void StlcListIteratorSetValue( const SList* a_pstList, const SIterator a_stIterator, void* a_pValue );
//const void* StlcListIteratorGetPointer( const SList* a_pstList, const SIterator a_stIterator ); 
//void StlcListIteratorNext( const SList* a_pstList, PSIterator a_pstIterator );
//void StlcListIteratorPrev( const SList* a_pstList, PSIterator a_pstIterator );
//void* StlcListIteratorAt( const SList* a_pstList, const SIterator a_stIterator, size_t a_szIndex );
//void StlcListIteratorNextN( const SList* a_pstList, PSIterator a_pstIterator, int a_nStep );
//void StlcListIteratorPrevN( const SList* a_pstList, PSIterator a_pstIterator, int a_nStep );
//int  StlcListIteratorDistance( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
//bool StlcListIteratorLess( const SList* a_pstList, const SIterator a_stIterFirst, const SIterator a_stIterSecond );
//bool StlcListIteratorBefore( const SIterator a_stIterFirst, const SIterator a_stIterSecond );